import 'package:flutter/material.dart';
import 'ChildCase.dart';
class ParentCase extends StatefulWidget {
  const ParentCase({ Key? key }) : super(key: key);
  // 一个向外

  @override
  _ParentCaseState createState() => _ParentCaseState();
}

class _ParentCaseState extends State<ParentCase> {
  // 向内
  int count = 10;   //父组件定义状态变量
  void updateValue(int value){  //父组件中声明函数向子组件传递数据
  // 只有被setState函数修饰的变量才是响应式变量
    setState(() {
      count = value;
    });
  // count = value; //非响应式变量
  }
  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.center,    //交叉轴对齐
      children: [
        const Text(
          '父组件标题',
          style: TextStyle(fontSize: 30),
        ),
        ChildCase(
          count:count,
          updateCallBack:updateValue
        )
      ],
    );
  }
}